<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>

    <body>
        <!-- 作业 -->
        <!-- 1.登录 使用vuex控制 -->
        <!-- 2.写一个计数器(同步+1 -1)(异步的+1 -1) -->
        <script>
            function ajax (option) {
                // 1.创建xhr对象
                let XHR = new XMLHttpRequest()

                // 2.发送请求
                XHR.open(option.type, option.url)

                // 3.post传参
                XHR.send('name=123&age=456')
                XHR.onreadystatechange = function (code) {
                    // 1
                    // 2
                    // 3
                    // 后端返回数据
                    if (code === 4) {
                        // 数据渲染到页面
                    }
                }
            }

            ajax({
                url: '',
                type: '',
                data: {},
                success: function (res) {
                    console.log(res);
                }
            })
            $.ajax({
                url: '',
                type: '',
                data: {}
            }).then(res => {
                console.log(res);
            })
        </script>
        <script>
            $.ajax({
                url: 'dsadsad',
                data: {},
                dataType: 'json',
                type: 'get',
                // success: function (res) {
                //     console.log(res);
                // }
            }).then(res => {
                console.log(res);

            })
        </script>
    </body>

</html>